package main

import (
	"fmt"
	"os"

	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

const (
	dbUser     string = "root"
	dbPassword string = "root"
	dbHost     string = "127.0.0.1"
	dbPort     int    = 3306
	dbName     string = "test"
)

var dns string = fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local",
	dbUser, dbPassword, dbHost, dbPort, dbName)

type User struct {
	gorm.Model
	Name string
}

func main() {
	db, err := gorm.Open("mysql", dns)
	if err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
	db.AutoMigrate(&User{})
	db.Close()
}
